package com.tanhua.admin.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tanhua.model.domain.Analysis;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;


public interface AnalysisMapper extends BaseMapper<Analysis> {

    //查询指定时间段段内的用户行为记录
    @Select("select * from tb_analysis where record_date between #{sd} and #{ed}")
    List<Analysis> thisYearRegisteredCount(@Param("sd") String sd, @Param("ed") String ed);

    //获得累计注册用户
    @Select("select sum(num_registered) from tb_analysis")
    Integer sumRegistered();

    //查询过去至今的累计活跃用户数
    @Select("select sum(num_active) from tb_analysis where record_date >=#{passDate}")
    Integer sumActiveByPassDate(String passDate);

    //查询指定日期的用户活跃数
    @Select("select sum(num_active) from tb_analysis where record_date =#{today}")
    Integer sumActiveByDate(String today);

    //查询指定日期的用户注册数
    @Select("select sum(num_registered) from tb_analysis where record_date =#{today}")
    Integer sumRegisteredByDate(String today);

    //查询指定日期的用户登录次数
    @Select("select sum(num_login) from tb_analysis where record_date =#{today}")
    Integer sumLoginByDate(String today);

}
